package com.hk.service.order.impl;

import java.util.List;

import org.springframework.stereotype.Service;

import com.hk.commons.HqlFilter;
import com.hk.commons.entity.pay.FYBackPayRecord;
import com.hk.dao.base.impl.BaseServiceImpl;
import com.hk.service.order.IFYBackPayRecord;

@Service
public class FyBackPayRecordImpl extends BaseServiceImpl<FYBackPayRecord>
		implements IFYBackPayRecord {

	@Override
	public FYBackPayRecord findById(long id) {
		return getById(id);
	}

	@Override
	public Long add(FYBackPayRecord u) {
		Long id = null;
		if (u != null && u.getOrderId() != null) {
			HqlFilter hqlFilter = new HqlFilter();
			hqlFilter.addEQFilter("orderId", u.getOrderId());
			List<FYBackPayRecord> records = findByFilter(hqlFilter);
			if (records.size() > 0) {// 已有则不添加
				return 0L;
			} else {
				// Long cts = System.currentTimeMillis();
				// u.setCts(cts);
				// String date = DateUtil
				// .transferLongToDate("yyyyMMddHHmmss", cts);
				// u.setOrderDate(date);
				super.save(u);
			}
		}
		return id;
	}

	@Override
	public Long add(FYBackPayRecord u, Integer companyId) {
		// TODO Auto-generated method stub
		return null;
	}
}
